/***************************************************************************
 *   Copyright (C) 2006 2007 2008 by ywchen2000                         *
 *   ywchen2000@gmail.com                                                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef TREE_H
#define TREE_H
#include<QString>
#include<QListWidget>
#include<QFileInfo>
#include <QStringList>
struct structnode//private
{
		QString value;
		struct structnode* left;
		struct structnode* right;
		structnode(const QString& str):value(str),left(NULL),right(NULL)
		{}
		structnode():left(NULL),right(NULL)
		{}
};
typedef struct structnode nodeprivate;
class tree:public QWidget
{
	Q_OBJECT
	public:
		tree(QWidget* parent=0);
		virtual ~tree(void);
		bool init(void);
		void close(void);
		void insert(const QString& text);
		void show_all(QListWidget* l);
		QStringList find(const QString& text);
	public slots:
		bool find(const QString& text,QListWidget* l);
	private:
		void FindFileRec(const nodeprivate* node,const QString& Text,QStringList& StrList);
	//	void private_show_all(const nodeprivate* node,QListWidget* l);
		void deletetree(nodeprivate* node);
		void display_result(nodeprivate* node,QListWidget* l);
		inline int ELFhash (char* key);         
		nodeprivate* head;
		nodeprivate** treearray;
		static const int mSize=10;
};
#endif
